package org.example.config.sequence.listeners;

import org.example.config.sequence.SpringConfigApplication;
import org.example.config.sequence.inspect.Inspector;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * 通过{@link Component @Component},{@link Bean @Bean}等注解声明方式加载，也可通过注册{@link BeanDefinition}方式加载
 * <p>
 * 本示例中通过{@link SpringConfigApplication @SpringConfigApplication}中{@link Bean @Bean}声明方式加载
 */
// @Component
public class MyApplicationListener implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        Inspector.log(MyApplicationListener.class, "onApplicationEvent");
        Inspector.print();
    }
}
